<%-- 
    Document   : index
    Created on : Dec 29, 2011, 3:58:44 PM
    Author     : xuanhung2401
--%>

<%@page import="model.SubCategoryModel"%>
<%@page import="entity.Category"%>
<%@page import="model.CategoryModel"%>
<%@page import="model.TagModel"%>
<%@page import="model.NewsModel"%>
<%@page import="entity.News"%>
<%@page import="entity.Tag"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/style.css" />
        <title>JSP Page</title>
        <% request.setCharacterEncoding("UTF-8"); %> 
    </head>
    <body>                      
        <%
        	SubCategoryModel subModel = new SubCategoryModel();        	
            NewsModel newsModel = new NewsModel();
            News n = null;
            List<News> list = newsModel.all();
            if(request.getAttribute("detail")!=null){                
                n = (News)request.getAttribute("detail");                                    
            }
        %>
	<div id="page-master">
    	<div id="header">        	
        </div>
        <div id="menu">
        	<ul class="menu-mainmenu clearafter">
            	<li class="first"><a href="<%= request.getContextPath() %>/index">Index</a></li>
                    <%
                        CategoryModel cateModel = new CategoryModel();
                        for (Category cate : cateModel.find()) {
                        %>
                            <li><a href="<%= request.getContextPath() %>/category/<%=cate.getAlias() %>"><%=cate.getTitle() %></a></li> 
                        <%                        
                        }
                    %>      
            </ul>
        </div>
        <div id="content">
        	<div id="leftsidecontent">
            	<div class="box-wrap">
                	<div class="box-categories">
                        
                        <div class="clearbreak"></div>                        
                    </div>
                    <div class="box-item news-detail">
                        <div class="box-item_inner">
                            
                            <h1 class="heading"><%=n.getTitle()%></h1>
                            <div class="news-content">
                                <h3 class="heading">
                                    <a href="<%= request.getContextPath() %>/category/<%=n.getCategory() %>"><%=cateModel.findByAlias(n.getCategory()).getTitle() %></a>&nbsp;
                                    <a href="<%= request.getContextPath() %>/sub-category/<%=n.getSubCategory()%>"><%=subModel.findByAlias(n.getSubCategory()).getTitle() %></a> 
                                    &nbsp;(<%=n.getDoc().toGMTString() %>)
                                </h3>
                                <div style="font-weight: bold">
                                     <%=n.getDescription()%>
                                </div> 
                                <div>
                                    <%
                                        if(n.getRelateUrls()!=null&&n.getRelateUrls().size()>0){
                                            for(String relateLink: n.getRelateUrls()){
                                                News relate = newsModel.findRelatedLink(relateLink);
                                                if(relate!=null&&relate.getContent()!=null){                                                                                                
                                                %>
                                                <p>> <a href="<%= request.getContextPath() %>/detail/<%=relate.getAlias() %>"><%= relate.getTitle() %></a></p>
                                                <%
                                                }
                                            }
                                        }                                        
                                    %>
                                </div>
                                </br>
                                <div>
                                    <%=n.getContent() %>
                                </div>
                                <div style="font-weight: bold; float: right">
                                    <%=n.getAuthor() %>
                                </div>  
                            </div>
                            <div class="tag">
                            	Tags : 
                                <%
                                    TagModel tagModel = new TagModel();
                            		Tag item;
                                    for(String tag: n.getTagged()){
                                    	item = tagModel.findByAlias(tag);
                                    	if(item.getTitle()!=null&&!item.getTitle().equalsIgnoreCase("")){
	                                   	%>
                                    		<a href="<%= tag%>"><%= tagModel.findByAlias(tag).getTitle() %></a>
	                                    <%}
                                    }
                                %>                            	                               
                                <div class="clearbreak"></div>
                            </div>
                            <%
                            	if(n.getOtherTags()!=null&& n.getOtherTags().size()>0){
                            		%>
                            			<div class="tag">
			                            	Other Tags : 
			                                 <%			                                    			                            		
			                                    for(String tag: n.getOtherTags()){
			                                    	item = tagModel.findByAlias(tag);
			                                    	if(item.getTitle()!=null&&!item.getTitle().equalsIgnoreCase("")){
				                                   	%>
			                                    		<a href="<%= tag%>"><%= tagModel.findByAlias(tag).getTitle() %></a>
				                                    <%}
			                                    }
			                                %>                                   	                               
			                                <div class="clearbreak"></div>
			                            </div>
                            		<%
                            	}
                            %>
                            
                        </div>
                    </div>
                    <div class="box-item">
                        <div class="box-item_inner">
                            <h3 class="heading"><a href="#">Related News</a></h3>
                            <ul class="news-item-listing">
                            	<li class="number-grey1"><a href="#">When you absolutely have to get … </a></li>
                                <li class="number-grey2"><a href="#">"Still a dangerous place to be"</a></li>
                                <li class="number-grey3"><a href="#">About that Iran explosion… </a></li>
                                <li class="number-grey4"><a href="#">Veto threat over detainee provis… </a></li>
                                <li class="number-grey5"><a href="#">Memo scandal: Pakistan's ambassa… </a></li>
                                <li class="number-grey6"><a href="#">U.S. may boost troop levels in M… </a></li>
                                <li class="number-grey7"><a href="#">Hillary Clinton to students: "Ge… </a></li>
                                <li class="number-grey8"><a href="#">When you absolutely have to get … </a></li>
                                <li class="number-grey9"><a href="#">"Still a dangerous place to be"</a></li>
                                <li class="number-grey10"><a href="#">About that Iran explosion… </a></li>
                            </ul>
                            <a class="readmore" href="#">Xem them</a>
                        </div>
                    </div>
                </div>
            </div>
            <div id="rightsidecontent">
            	<div class="box-wrap">
                	<div class="box-item search">
                        <div class="box-item_inner">
                            <h3 class="heading">Search</h3>
                            <form>
                            	<input type="text" />
                                <!-- <button type="submit">Tim kiem</button> -->
                            </form>
                        </div>
                    </div>
                    
                    <div class="box-item">
                        <div class="box-item_inner">
                            <h3 class="heading"><a href="#">Hot Topic</a></h3>
                            <ul class="news-item-listing">                                
                                    <%
                                        int count = 1;
                                        for(News obj: list){
                                            
                                            %>
                                                <li class="number-red<%=count %>"><a href="<%= request.getContextPath() %>/detail/<%=obj.getAlias() %>"><%=obj.getTitle() %></a></li>
                                            <%     
                                            count ++;
                                        }
                                    %>                                                                       
                            </ul>                            	
                            <a class="readmore" href="#">Xem them</a>
                        </div>
                    </div>
                    <div class="box-item">
                        <div class="box-item_inner">
                            <h3 class="heading"><a href="#">Hot news</a></h3>
                            <ul class="news-item-listing">
                            	<%
                                        count = 1;
                                        for(News obj: list){
                                            
                                            %>
                                                <li class="number-red<%=count %>"><a href="<%= request.getContextPath() %>/detail/<%=obj.getAlias() %>"><%=obj.getTitle() %></a></li>
                                            <%     
                                            count ++;
                                        }
                                    %>     
                            </ul>
                            <a class="readmore" href="#">Xem them</a>
                        </div>
                    </div>                    
                    <div class="box-item tag-suggestion">
                        <div class="box-item_inner">
                            <h3 class="heading">Tags Suggestion</h3>
                            <div class="tag">
                            	<a href="#">MacBook Air</a>
                                <a href="#">Apple iPad</a>
                                <a href="#">Samsung Galaxy</a>
                                <a href="#">Motorola Droid</a>
                                <a href="#">Samsung Epic Touch</a>
                                <a href="#">iPhone 4S</a>
                                <a href="#">PC World</a>
                                <a href="#">Kindle</a>
                                <a href="#">Kindle Fire</a>
                                <div class="clearbreak"></div>
                            </div>
                        </div>
                    </div>
                    <div class="clearbreak"></div>
                </div>
            </div>
            <div class="clearbreak"></div>
        </div>
        <div id="footer">
        	Luutrutin.com © 2011 Cable News Network. Turner Broadcasting System, Inc. All Rights Reserved.
        </div>
    </div>
</body>           
</html>
